home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Graphics Programming (2nd Edition)
/
Visual Basic Graphics Programming 2nd Edition.iso
/
OldSrc
/
CH2
/
SRC
/
FILLMODE.FRM
< prev
next >
Wrap
Text File
|
1996-04-18
|
4KB
|
132 lines
VERSION 4.00
Begin VB.Form FillModeForm
AutoRedraw = -1 'True
Caption = "Polygon Fill Mode"
ClientHeight = 3780
ClientLeft = 1545
ClientTop = 1815
ClientWidth = 6330
Height = 4470
Left = 1485
LinkTopic = "Form1"
ScaleHeight = 252
ScaleMode = 3 'Pixel
ScaleWidth = 422
Top = 1185
Width = 6450
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileExit
Caption = "E&xit"
End
End
End
Attribute VB_Name = "FillModeForm"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load()
Const XMOVE = 140
Const YMOVE = 120
Dim Points(0 To 10) As POINTAPI
#If Win32 Then
Dim NumPoints(0 To 1) As Long
#Else
Dim NumPoints(0 To 1) As Integer
#End If
Dim brush As Integer
Dim old_brush As Integer
Dim old_mode As Integer
Dim i As Integer
' Counterclockwise star.
Points(0).x = 72: Points(0).y = 0
Points(1).x = 8: Points(1).y = 119
Points(2).x = 133: Points(2).y = 24
Points(3).x = 16: Points(3).y = 37
Points(4).x = 120: Points(4).y = 108
Points(5).x = 72: Points(5).y = 0
NumPoints(0) = 6
' Counterclockwise rectangle.
Points(6).x = 43: Points(6).y = 110
Points(7).x = 108: Points(7).y = 110
Points(8).x = 108: Points(8).y = 16
Points(9).x = 43: Points(9).y = 16
Points(10).x = 43: Points(10).y = 110
NumPoints(1) = 5
' Fill with a red brush.
brush = CreateSolidBrush(vbRed)
old_brush = SelectObject(hdc, brush)
' Draw the star ALTERNATE.
old_mode = SetPolyFillMode(hdc, ALTERNATE)
If Polygon(hdc, Points(0), NumPoints(0)) = 0 Then Exit Sub
' Move down.
For i = LBound(Points) To UBound(Points)
Points(i).y = Points(i).y + YMOVE
Next i
' Draw the star WINDING.
old_mode = SetPolyFillMode(hdc, WINDING)
If Polygon(hdc, Points(0), NumPoints(0)) = 0 Then Exit Sub
' Move up and to the right.
For i = LBound(Points) To UBound(Points)
Points(i).x = Points(i).x + XMOVE
Points(i).y = Points(i).y - YMOVE
Next i
' Draw the star and box ALTERNATE.
old_mode = SetPolyFillMode(hdc, ALTERNATE)
If PolyPolygon(hdc, Points(0), NumPoints(0), 2) = 0 Then Exit Sub
' Move down.
For i = LBound(Points) To UBound(Points)
Points(i).y = Points(i).y + YMOVE
Next i
' Draw the star and box WINDING.
old_mode = SetPolyFillMode(hdc, WINDING)
If PolyPolygon(hdc, Points(0), NumPoints(0), 2) = 0 Then Exit Sub
' Move up and to the right.
For i = LBound(Points) To UBound(Points)
Points(i).x = Points(i).x + XMOVE
Points(i).y = Points(i).y - YMOVE
Next i
' Make the rectangle clockwise.
i = Points(7).x: Points(7).x = Points(9).x: Points(9).x = i
i = Points(7).y: Points(7).y = Points(9).y: Points(9).y = i
' Draw the star and box ALTERNATE.
old_mode = SetPolyFillMode(hdc, ALTERNATE)
If PolyPolygon(hdc, Points(0), NumPoints(0), 2) = 0 Then Exit Sub
' Move down.
For i = LBound(Points) To UBound(Points)
Points(i).y = Points(i).y + YMOVE
Next i
' Draw the star and box WINDING.
old_mode = SetPolyFillMode(hdc, WINDING)
If PolyPolygon(hdc, Points(0), NumPoints(0), 2) = 0 Then Exit Sub
' Delete the brush.
brush = SelectObject(hdc, old_brush)
If DeleteObject(brush) = 0 Then Exit Sub
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub